// WndMultiLan.cpp : implementation file
//

#include "stdafx.h"
#include "WndMultiLan.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWndMultiLan

CWndMultiLan::CWndMultiLan(LPCTSTR szName)
:m_strDlgName(szName),
m_bInited(FALSE)
{
}

CWndMultiLan::~CWndMultiLan()
{
}


BEGIN_MESSAGE_MAP(CWndMultiLan, CWnd)
	//{{AFX_MSG_MAP(CWndMultiLan)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_MESSAGE(UM_LANGUAGE_CHANDGED, OnLanguageChanged)
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CWndMultiLan message handlers

LRESULT CWndMultiLan::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(!m_bInited)
	{
		if (message == WM_PAINT)
		{
			if (!g_lanManager.IsRead())
			{
				//if (g_lanManager.GetDefLanIndex() == g_lanManager.GetCurLanIndex())
				LoadLanguage(FALSE);
			}
			else
			{
				LoadLanguage(TRUE);
			}

			m_bInited = TRUE;
		}
	}

	return CWnd::WindowProc(message, wParam, lParam);
}

void CWndMultiLan::LoadLanguage(BOOL bRead)
{
	if(bRead)
	{
		g_lanManager.WndReadLan(m_strDlgName, this);
	}
	else
	{
		g_lanManager.WndWriteLan(m_strDlgName, this);
	}
}

LRESULT CWndMultiLan::OnLanguageChanged(WPARAM wParam, LPARAM lParam)
{
	LoadLanguage(TRUE);
	
	return 0;
}


CString		CWndMultiLan::GetSkinFile(LPCTSTR szKeyName)
{
	return g_UIManager.GetSkinFile(m_strDlgName, szKeyName);
}
COLORREF CWndMultiLan::GetColor(LPCTSTR szKeyName, COLORREF clrDefault)
{
	return g_UIManager.GetColor(m_strDlgName, szKeyName, clrDefault);
}

